package cn.wolfcode.trip.base.service.impl;

import cn.wolfcode.trip.base.domain.PictureShare;
import cn.wolfcode.trip.base.domain.User;
import cn.wolfcode.trip.base.mapper.PictureShareMapper;
import cn.wolfcode.trip.base.service.IPictureShareService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import java.util.Date;

/**
 * 照片分享业务层
 *
 * @author Wangyk
 * @date 2019/1/15 16:30
 */
@Controller
public class PictureShareServiceImpl implements IPictureShareService {
    @Autowired
    private PictureShareMapper pictureShareMapper;

    /**
     * 保存一个图片分享
     *
     * @param pictureShare 图片分享的数据
     * @param currentUser  分享的用户
     */
    @Override
    public void saveAPictureShare(PictureShare pictureShare, User currentUser) {
        //设置当前用户
        pictureShare.setUser(currentUser);
        //设置分享时间
        pictureShare.setReleaseTime(new Date());
        //保存
        pictureShareMapper.insert(pictureShare);
    }
}
